/**
 * 
 */
package com.softqin.washer.db;

import java.util.List;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * 
 * @ClassName: OrdersDatabase
 * 
 * @Description: Orders数据库
 * 
 * @author 杨守志
 * 
 * @date 2015-1-13 下午5:18:54
 */
public class OrdersDatabase extends SQLiteOpenHelper implements
		DatabaseOperation {
	private static final String DB_NAME="order.db";
	private static final int VERSION=1;
	private static final String TABLE_NAME="order";
	private static final String ID="_id";
	public static final String TOKENID = "tokenid";
	public static final String STOKENID = "stokenid";
	public static final String DTOKENID = "dtokenid";
	public static final String BTOKENID = "btokenid";
	public static final String CARTOKENID = "cartokenid";
	public static final String ADDRTOKENID = "addrtokenid";
	public static final String CREATEDATE = "createddate";
	public static final String DESCRIPTION = "description";
	
	private Context context;
	private SQLiteDatabase dbReadDatabase;
	private SQLiteDatabase dbWriteDatabase;
	
	public OrdersDatabase(Context context){
		super(context, DB_NAME, null, VERSION);
		this.context=context;
		dbReadDatabase=this.getReadableDatabase();
		dbWriteDatabase=this.getWritableDatabase();
		
	}

	/**
	 * @param context
	 * @param name
	 * @param factory
	 * @param version
	 */
	public OrdersDatabase(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
	}


	@Override
	public SQLiteDatabase getReadableDb() {
		return dbReadDatabase;
	}

	@Override
	public SQLiteDatabase getWritableDb() {
		return dbWriteDatabase;
	}

	@Override
	public void initDatabase() {

	}

	@Override
	public List<?> findAll() {
		return null;
	}

	@Override
	public void insert(String sql) {

	}

	@Override
	public void delete(String sql) {

	}

	@Override
	public void update(String sql) {

	}

	@Override
	public void select(String sql) {

	}

	@Override
	public String getDatabaseVersionName() {
		return null;
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE " + TABLE_NAME + "(" + ID
				+ " INTEGER PRIMARY KEY AUTOINCREMENT ," + TOKENID
				+ " VARCHAR NOT NULL DEFAULT \"\"," + STOKENID
				+ " VARCHAR NOT NULL DEFAULT \"\"," + DTOKENID
				+ " VARCHAR NOT NULL DEFAULT \"\"," + BTOKENID
				+ " VARCHAR NOT NULL DEFAULT \"\"," + CARTOKENID
				+ " VARCHAR NOT NULL DEFAULT \"\"," + ADDRTOKENID
				+ " VARCHAR NOT NULL DEFAULT \"\"," + CREATEDATE
				+ " LONG NOT NULL DEFAULT \"\"," + DESCRIPTION
				+ " VARCHAR NOT NULL DEFAULT \"\")");

	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

	}

}
